package com.flow.engine.controller;

import com.flow.engine.dto.FlowTemplateDTO;
import com.flow.engine.entity.FlowNodeTemplate;
import com.flow.engine.entity.FlowTemplate;
import com.flow.engine.service.FlowTemplateService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/flowTemplate")
public class FlowTemplateController {

    @Autowired
    private FlowTemplateService service;


    @RequestMapping("/queryList")
    public List<FlowTemplate> queryList(FlowTemplate record) {
        return service.queryList(record);
    }

    @RequestMapping("/queryListPage")
    public List<FlowTemplate> queryListPage(@RequestParam(defaultValue = "10",required = false,value = "pageSize") Integer pageSize,@RequestParam(defaultValue = "1",required = false,value = "pageNum") Integer pageNum, FlowTemplate record) {
        return service.queryListPage(pageNum,pageSize,record);
    }

    public List<FlowNodeTemplate> queryNodeList(String userId,Long flowId) {
      return   service.queryNodeList(userId,flowId);
    }

    @PostMapping("createTemplate")
    public Boolean createFlowTemplate(@RequestBody FlowTemplateDTO templates) {
        return service.createFlowTemplate(templates);
    }

}
